package com.lixin.exception;

import com.lixin.utils.Result;
import com.lixin.utils.ResultCode;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(HttpMessageNotReadableException.class)
    @ResponseBody
    public Result paramException() {
        return Result.build(ResultCode.PARAM_ERROR);
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result exception() {
        return Result.build(ResultCode.SERVER_ERROR);
    }
}
